﻿    <?php 
    if(!empty($data)) {
    
		$data = $bs->productArray($data);
		if ($data != null) {
			$totalrow = count($data);
			if (!isset($curentpage))
				$curentpage = 1;
				$rows_per_page = 6; 
				$page_start = ( $curentpage - 1 ) * $rows_per_page;
			$page_end = $curentpage * $rows_per_page; 
			$numpages = ceil($totalrow/$rows_per_page);
			if ( $numpages > 1 ){
				$list_page = " <td> Page: </td>";
				for ( $i = 1; $i <= $numpages; $i++ ){
					if ( $i == $curentpage ){
						$list_page .= " <td>[ <b>{$i}</b> ]</td> ";
					}else{
						$list_page .= "<td><a href='". $this->webroot .'products/recent/currentpage:'. $i ."'> {$i} </a></td>";
					}
				}
			}
			$i =0;
			foreach ($data as  $row): 
				if ( $i >= $page_start && $i < $page_end){
	
	
    //debug($data);
    
     ?>

			<ul class="products cols">
			<?php// foreach ($data as  $row) { ?>
			<li id="product_<?php echo $row['id']; ?>">

			<a href="<?php echo $this->webroot;?>products/show/<?php echo $row['id'];?>" class="p_img"><img width="100%" height="140px"style="margin-bottom:10px;" src='<?php echo $this->webroot;?><?php echo $row['images']; ?>'></img></a>
			<!--a href="<?php echo $this->webroot;?>products/show/<?php// echo $row['id'];?>" class="p_img"><img width="100%" height="140px"style="margin-bottom:10px;" src='<?php //echo $this->webroot;?>img/uploads/<?php //echo $row['images']; ?>'></img></a-->

			<div class="hide">
				<?php
					$img2=explode(";",$row['images']);
					if (count($img2)>0) 
					 echo '<img class="product_preview_img" src="'.$this->webroot.$img2[0].'" />';
				  // echo '<img class="product_preview_img" src="'.$this->webroot.'img/uploads/'.$img2[0].'" />';
				?>
			</div>
			<script>product_tooltip("product_<?php echo $row['id']; ?>");</script>
		  
			<div id="info_product">
			<a href="<?php echo $this->webroot;?>products/show/<?php echo $row['id']; ?>" class="p_name"><?php echo ($row['name']); ?></a> 
			<div id="code_product"><?php echo $row['code']; ?></div>
			<span class="p_price"><?php echo $row['price']; ?></span>
			</div>
			
			</li>
    <?php } 
		$i++;
		endforeach; 
		}
	
	?>
    </ul>
    <?php } ?>
	
<?php  if (isset($list_page))
			echo $list_page;
?>	
